package com.ethan.http;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.*;

/**
 * @author ethan
 * create 2018-04-15 下午3:02
 * desc
 **/
public class HttpTest {
    public static void main(String[] args){


    ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
    .setNameFormat("demo-pool-%d").build();
        ExecutorService executorService =new ThreadPoolExecutor(20,20,0L,TimeUnit.MICROSECONDS, new ArrayBlockingQueue<Runnable>(10000),namedThreadFactory,new ThreadPoolExecutor.AbortPolicy());

        for (int i = 0; i < 100000000; i++) {
            executorService.execute(HttpTest::run);
        }

    }

    public static void run(){
        String url ="";
        //http://localhost:8080/test/rateLimiterTest";
        url ="http://l-noahmfngdtmo1.auto.beta.cn0.qunar.com:8080/justfortest/batchQueryBaseOrderDetailsByOrderNos?"
                +"orderNos=xep180402133013230,xep180402033014100,xep180401133015328,xep180330220020996,xep180330050018666," +
                "xep180330161050490,xep180402143052938,xep180402142952924,xep180402140218793,xep180330161708852," +
                "xep180402053156036,xep180404103226670,xep180329170028978,xep180329121349225";
        String result = HttpUtils2.get(url);
        System.out.println(result);
    }
}

//
//    ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
//            .setNameFormat("demo-pool-%d").build();
//    ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1,
//            0L, TimeUnit.MILLISECONDS,
//            new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
//
//    singleThreadPool.execute(()-> System.out.println(Thread.currentThread().getName()));
//            singleThreadPool.shutdown();
//
//
//
//public class TimerTaskThread extends Thread {
//    public TimerTaskThread(){
//        super.setName("TimerTaskThread"); …
//    }